<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

$THEME->addBreadcrumb($this->adminUrl, $this->lang('breadcrumb_new_folder'));


if(Antz_IntelliForm::submitted('new_folder')){
	$error = false;

	$title = post('title');
	$id = preg_replace('/[^a-z0-9A-Z]/', '', post('id'));
	$parent = preg_replace('/[^a-z0-9A-Z]/', '', post('parent'));

	if(trim($title)==''){
		$error = true;
		JFX::addError($this->lang('invalid_folder_title'));
	}

	if($DB->countRows($CONFIG->dbprefix.$this->keyname.'_folders', "id = '{$id}'")>0){
		JFX::addError($this->lang('invalid_folder_id'));
		$error = true;
	}

	if($DB->countRows($CONFIG->dbprefix.$this->keyname.'_folders', "id = '{$parent}'")==0){
		JFX::addError($this->lang('invalid_folder_id'));
		$error = true;
	}

	if(!$error){
		$this->addFolder($parent, $id);
		JFX::addSuccess($this->lang('new_folder_success'));
	}


}








$parentOpts = array();

$this->makeFolderDropMenu($parentOpts, '', 0, post('parent', 'root'));

$formFields = array(
	array(
		'name' => 'parent',
		'label' => $this->lang('new_folder_parent'),
		'value' => post('parent', 0),
		'type' => 'select',
		'options' => $parentOpts
	),
	array(
		'name' => 'id',
		'label' => $this->lang('new_folder_id'),
		'value' => post('id'),
		'type' => 'text'
	),
	array(
		'name' => 'title',
		'label' => $this->lang('new_folder_title'),
		'value' => post('title'),
		'type' => 'text'
	),
	array(
		'name' => 'submitBtn',
		'type' => 'submit',
		'value' => $this->lang('new_folder_submit'),
		'label' => '&nbsp;'
	)
);

echo JFX::makeRapidForm($formFields, $this->lang('new_folder_legend'), 'new_folder');



